package cn.tedu.icop.user.controller;
import cn.tedu.icop.api.model.RestResult;
import cn.tedu.icop.api.model.RestResultUtils;
import cn.tedu.icop.user.service.WxLoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class WechatLoginController {
    @Autowired
    private WxLoginService wxLoginService;
    @GetMapping("/user/wx/login")
    public RestResult<Integer> wxLogin(@RequestParam("code") String code,
                                       @RequestParam("nickName") String nickName){
        log.debug("code is {}",code);
        log.debug("nickName is {}",nickName);
        log.debug("调用业务层对象{}的{}方法执行登录操作",wxLoginService,"login");
        Integer userId = wxLoginService.login(code,nickName);
        return RestResultUtils.success(userId);
    }
}
